package com.dayu.store.domain;

import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.dayu.common.annotation.Excel;
import com.dayu.common.core.domain.BaseEntity;

/**
 * 门店回收对象 store_collect
 *
 * @author HK
 * @date 2021-07-02
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class StoreCollect extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** 回收编号 */
    @Excel(name = "回收编号")
    private Long storeId;

    /** 状态 */
    @Excel(name = "状态", readConverterExp = "1=可用,2=待发货,3=待收货,4=已收货,5=关闭")
    private Integer status;

    /** 财务状态 */
    @Excel(name = "财务状态", readConverterExp = "1=待审核,2=已审核")
    private Integer billStatus;

    /** 机型编号*/
    private Long modelId;
    /** 机型名称 */
    @Excel(name = "机型名称")
    private String modelName;

    /** 机型串号 */
    @Excel(name = "机型串号")
    private String modelSn;

    /** 快递信息 */
    @Excel(name = "快递信息")
    private String expInfo;

    /** 公司信息 */
    private String companyInfo;
    @Excel(name = "供应商")
    private String supplierName;
    @Excel(name = "门店")
    private String storeName;
    @Excel(name = "店员")
    private String checkName;

    /** 报价金额 */
    @Excel(name = "报价金额")
    private BigDecimal price;

    /** 返利一 */
    @Excel(name = "返利一")
    private BigDecimal priceOne;

    /** 返利二 */
    @Excel(name = "返利二")
    private BigDecimal priceTwo;

    /** 返利三 */
    @Excel(name = "返利三")
    private BigDecimal priceThree;

    @Excel(name = "快递费")
    private BigDecimal expPrice;

    @Excel(name = "合计")
    private BigDecimal totalPrice;

    /** 转账方式 */
    @Excel(name = "转账方式", readConverterExp = "1=支付宝,2=微信,3=银行卡")
    private Integer tranType;

    /** 转账人 */
    private String tranName;

    /** 报价师 */
    private String offerName;

    @Excel(name = "报价师")
    private String offerNickName;

    @Excel(name = "登记人")
    private String createBy;

    /** 报价时间 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "报价时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date offerTime;

    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "收货时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date collectTime;

    /** 备注 */
    @Excel(name = "备注")
    private String remark;

    /** 收货人信息 */
    private String collectInfo;

    /** 审核人信息 */
    private String checkInfo;

    /** 公司id*/
    private Long companyId;

    /** 门店id*/
    private Long companyStoreId;

    /** 店员id*/
    private Long clerkId;

    private String payScan;

    private Integer hasPay;
    /* 用户备注*/
    private String userRemark;

    private Integer useTime;

    public void setTotalPrice(BigDecimal totalPrice) {
        if(price != null) {
            totalPrice = price;
        }
        if(priceOne != null) {
            totalPrice = totalPrice.add(priceOne);
        }
        if(priceTwo != null) {
            totalPrice = totalPrice.add(priceTwo);
        }
        if(priceThree != null) {
            totalPrice = totalPrice.add(priceThree);
        }
        if(expPrice != null) {
            totalPrice = totalPrice.add(expPrice);
        }
        this.totalPrice = totalPrice;
    }
    public void setExportCompany() {
        this.supplierName = companyInfo;
        if(StringUtils.isEmpty(companyInfo))
            return;
        String[] arr = companyInfo.split(" ");
        switch (arr.length) {
            case 1 : supplierName = arr[0];break;
            case 2 : supplierName = arr[0]; storeName = arr[1];break;
            case 3 : supplierName = arr[0]; storeName = arr[1]; checkName = arr[2];break;
            default: this.supplierName = companyInfo;
        }
    }
}
